package com.heima.article.controller.v1;

import com.heima.article.service.ArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xiaoxiaode
 * @date 2021/9/25 19:12
 **/

@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {



    @Autowired
    private ArticleService articleService;


    /*
    * 首页  默认加载最新数据
    *
    * */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
        ResponseResult responseResult = articleService.load(dto, ArticleConstants.LOADTYPE_LOAD_NEW);
        return responseResult;
    }

    /*
    *  下拉加载更多数据
    *
    * */
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto dto){
        ResponseResult responseResult = articleService.load(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
        return responseResult;
    }

    /*
    *  上拉加载更多数据
    *
    * */
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto dto){
        ResponseResult responseResult = articleService.load(dto, ArticleConstants.LOADTYPE_LOAD_NEW);
        return responseResult;
    }




}
